<?php

namespace IDock\Insurance\ACIC\Request;

use Exception;
use IDock\Insurance\ACIC\ACICEnums;
use IDock\Insurance\ACIC\Response\ProposalRecallResponse;
use IDock\Insurance\ACIC\Response\UnderwritingRecallResponse;
use IDock\Visitor\ProposalRecallVisitor;

class UnderwritingRecallRequest extends AllACICRequest
{
    protected $code = 'V02';

    protected $response = UnderwritingRecallResponse::class;

    protected $urlTip = '核保撤回';

    /**
     * @var ProposalRecallVisitor $visitor
     */
    protected $visitor;

    /**
     * @return array
     * @throws Exception
     */
    public function generate(): array
    {
        $param = [];

        if ($this->visitor->ciInquiryNo) {
            $param['AppInfo'][] = [
                'AppNo' => $this->visitor->ciInquiryNo,
                'ProdNo' => ACICEnums::$TCI
            ];
        }

        if ($this->visitor->biInquiryNo) {
            $param['AppInfo'][] = [
                'AppNo' => $this->visitor->biInquiryNo,
                'ProdNo' => ACICEnums::$VCI
            ];
        }

        return $param;
    }
}